Purity and Side Effect Analysis for Java Programs
نویسندگان
چکیده
We present a new purity and side effect analysis for Java programs. A method is pure if it does not mutate any location that exists in the program state right before the invocation of the method. Our analysis is built on top of a combined pointer and escape analysis, and is able to determine that methods are pure even when the methods mutate the heap, provided they mutate only new objects. Our analysis provides useful information even for impure methods. In particular, it can recognize read-only parameters (a parameter is readonly if the method does not mutate any objects transitively reachable from the parameter) and safe parameters (a parameter is safe if it is read-only and the method does not create any new externally visible heap paths to objects transitively reachable from the parameter). The analysis can also generate regular expressions that characterize the externally visible heap locations that the method mutates. We have implemented our analysis and used it to analyze several applications. Our results show that our analysis effectively recognizes a variety of pure methods, including pure methods that allocate and mutate complex auxiliary data structures.
منابع مشابه
Side effect and purity checking in Java: a review
“Side effects” in programming language expressions have long been regarded as making programs hard to understand and prone to error. In objectoriented programming languages, proposals have been made for enforcing “purity” (an absence of side effects) in the methods of objects, thus restricting the use of side effects. We examine the different approaches to defining and checking purity and side ...
متن کاملA Combined Pointer and Purity Analysis for Java Programs
We present a new method purity analysis for Java programs. A method is pure if it does not mutate any location that exists in the program state right before method invocation. Our analysis is built on top of a combined pointer and escape analysis for Java programs and is capable of determining that methods are pure even when the methods do heap mutation, provided that the mutation affects only ...
متن کاملSoftware Component Technology Group
Background The Software Component Technology Group has developed some analysis tools for Java programs, which need purity information about the methods in the program. Purity information means, the analyze tools have to know if a method mutates any object that exists before the method invocation (not pure) or not (pure). Till now, the purity information has to be written to the tool with an XML...
متن کاملJPure: A Modular Purity System for Java
Purity Analysis is the problem of determining whether or not a method may have side-effects. This has applications in automatic parallelisation, extended static checking, and more. We present a novel purity system for Java that employs purity annotations which can be checked modularly. This is done using a flow-sensitive, intraprocedural analysis. The system exploits two properties, called fres...
متن کاملMostly-Functional Behavior in Java Programs
We present a lightweight type-and-effect system for Java programs that features two major innovations over extant object-oriented effects systems: initialization effects, which are writes to an object’s state while it is being constructed, and quiescing fields, which are fields that are never written after an object is constructed. We also present a novel taxonomy of degrees of method purity in...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2005